// Decompiled by DJ v3.9.9.91 Copyright 2005 Atanas Neshkov  Date: 2008-9-8 17:54:16
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   t_role_EditMap.java

package com.creawor.hz_market.t_info_level;

import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;

import com.creawor.imei.base.AbsEditMap;

// Referenced classes of package com.creawor.hz_market.t_role:
//            t_role, t_role_Form

public class TInfoLevel_EditMap extends AbsEditMap
{

    public TInfoLevel_EditMap()
    {
    }

    public void add(TInfoLevel_Form vo)
        throws HibernateException
    {
    	TInfoLevel po = new TInfoLevel();
        try
        {
            po.setId(Integer.parseInt(vo.getId()));
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        try
        {
            po.setName(vo.getName());
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        try
        {
            po.setRemark(vo.getRemark());
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        Session session = beginTransaction();
        try
        {
            session.save(po);
            String[] seqs = vo.getSeqs();
            String[] names=vo.getNames();
            save_t_info_type_levels(po, session, names,seqs);
            endTransaction(true);
        }
        catch(Exception e)
        {
            endTransaction(false);
            e.printStackTrace();
            throw new HibernateException(e);
        }
    }

    private void save_t_info_type_levels(TInfoLevel po, Session session,
    		String[] leavelName, String[] leavelSeq)  throws HibernateException
    {
    	for(int i = 0; i < leavelName.length; i++);
           // session.save(new TInfoTypeLevel(po.getId(),leavelName[i],Integer.parseInt(leavelSeq[i])));

		
	}

	public void delete(TInfoLevel_Form vo)
        throws HibernateException
    {
        String id = vo.getId();
        delete(id);
    }

    public void delete(String id)
        throws HibernateException
    {
        Session session = beginTransaction();
        try
        {
        	TInfoLevel po = (TInfoLevel)session.load(TInfoLevel.class, new Integer(id));
            session.delete(po);
            endTransaction(true);
        }
        catch(HibernateException e)
        {
            e.printStackTrace();
            endTransaction(false);
        }
    }

    public void update(TInfoLevel_Form vo)
        throws HibernateException
    {
        //System.out.println((new StringBuilder("upload t_role,id=")).append(vo.getId()).toString());
        
        Session session = beginTransaction();
        String id = vo.getId();
        TInfoLevel po = (TInfoLevel)session.load(TInfoLevel.class, new Integer(id));
        try
        {
            po.setId(Integer.parseInt(vo.getId()));
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        try
        {
            po.setName(vo.getName());
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        try
        {
            po.setRemark(vo.getRemark());
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        try
        {
            session.update(po);
            
            
            save_t_info_type_levels(po, session, vo.getNames(),vo.getSeqs());
            endTransaction(true);
        }
        catch(Exception e)
        {
            endTransaction(false);
            e.printStackTrace();
            throw new HibernateException(e);
        }
    }

    static Class class$0;
}